﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data;
using System.Data.SqlClient;

namespace ACNetMusic
{
    class SongDAO : DataProvider
    {
        public ArrayList getSongsList()
        {
            connect();
            string sql = "SELECT * FROM Songs";
            adapter = new SqlDataAdapter(sql, connection);
            DataSet dataset = new DataSet();
            adapter.Fill(dataset);
            ArrayList arr = ConverDataSetToArrayList(dataset);
            disconnect();
            return arr;
        }

        protected override object GetDataFromDataRow(DataTable dt, int i)
        {
            SongDTO info = new SongDTO();
            info.Ip = dt.Rows[i]["IP"].ToString();
            info.Port = dt.Rows[i]["Port"].ToString();
            info.Name = dt.Rows[i]["Name"].ToString();
            info.Musician = dt.Rows[i]["Musician"].ToString();
            info.Singer = dt.Rows[i]["Singer"].ToString();
            info.Size = float.Parse(dt.Rows[i]["Size"].ToString());
            return (object)info;
        }
    }
}
